Handle partial writes.
authorMatthias Clasen <mclasne@redhat.com>
Wed, 16 Jan 2008 17:38:13 +0000 (17:38 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 16 Jan 2008 17:38:13 +0000 (17:38 +0000)
2008-01-15  Matthias Clasen  <mclasne@redhat.com>

        * gdk-pixbuf-io.c (save_to_stream): Handle partial writes.

svn path=/trunk/; revision=19380

gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.c

index 1670d22e18247e240e333a4a9bb8e8d9c908bf2d..5e38b4bf1180900ccf6a8b7df66704ec8f5ab85a 100644 (file)
@@ -1,3 +1,7 @@
+2008-01-15  Matthias Clasen  <mclasne@redhat.com>
+
+       * gdk-pixbuf-io.c (save_to_stream): Handle partial writes.
+
 2008-01-16  Michael Natterer  <mitch@imendio.com>
 
        * gdk-pixbuf-io.c (save_to_stream): fix signature of this function
index 7c3ed83b824398d540a1aa0291cefd6a37da0845..206ed7962c59619e3e0783be721cc47d7e8932b9 100644 (file)
@@ -2218,24 +2218,32 @@ save_to_stream (const gchar  *buffer,
                gpointer      data)
 {
        SaveToStreamData *sdata = (SaveToStreamData *)data;
+       gsize remaining;
+       gssize written;
         GError *my_error = NULL;
-       gsize n;
 
-       n = g_output_stream_write (sdata->stream, 
-                                   buffer, count, 
-                                   sdata->cancellable, 
-                                   &my_error);
-       if (n != count) {
-               if (!my_error) {
-                        g_set_error (error,
-                                     G_IO_ERROR, 0,
-                                     _("Error writing to image stream"));
-                }
-                else {
-                        g_propagate_error (error, my_error);
-                }
-                return FALSE;
+       remaining = count;
+       written = 0;
+       while (remaining > 0) {
+               buffer += written;
+               remaining -= written;
+               written = g_output_stream_write (sdata->stream, 
+                                                buffer, remaining, 
+                                                sdata->cancellable, 
+                                                &my_error);
+               if (written < 0) {
+                       if (!my_error) {
+                               g_set_error (error,
+                                            G_IO_ERROR, 0,
+                                            _("Error writing to image stream"));
+                       }
+                       else {
+                               g_propagate_error (error, my_error);
+                       }
+                       return FALSE;
+               }
        }
+
        return TRUE;
 }